#ifndef MODELWIDGET_H
#define MODELWIDGET

#include <QWidget>
#include <Qt3DCore/QEntity>
#include <Qt3DRender/QCamera>
#include <Qt3DCore/QTransform>
#include <Qt3DRender/QMesh>
#include <QCheckBox>

class ModelWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ModelWidget(QWidget *parent = 0);
    virtual ~ModelWidget();

protected:
    // reimplementation needed to handle resize events
    // http://doc.qt.io/qt-5/qwidget.html#resizeEvent
//    void resizeEvent(QResizeEvent *event);

private:
    QWidget *createModelPanel();
    void createCuboid(int containerWidth, int containerHeight);
    void createModel(int containerWidth, int containerHeight);
    QWidget *createOpPanel();

signals:
    void cuboidScaleChanged(float scale);
    void cuboidRotationChanged(float rotationX, float rotationY, float rotationZ);
    void modelScaleChanged(float scale);
    void modelRotationChanged(float rotationX, float rotationY, float rotationZ);

public slots:
//    void resizeView(QSize size);
    void onFileOpen(const QString &filePath);

private slots:
    void setCuboidEnabled(int enabled);
    void setModelEnabled(int enabled);
    void scale(const QString &text);
    void rotateX(int rotation);
    void rotateY(int rotation);
    void rotateZ(int rotation);

private:
    Qt3DCore::QEntity *rootEntity;
    Qt3DRender::QCamera *camera;
    Qt3DCore::QEntity *cuboidEntity;
    Qt3DCore::QTransform *cuboidTransform;
    Qt3DCore::QEntity *modelEntity;
    Qt3DRender::QMesh *modelMesh;
    Qt3DCore::QTransform *modelTransform;
    QCheckBox *modelCheckBox;
};

#endif // MODELWIDGET
